From ea82fa6d63303e98960e5ece6b48e95789cc7c38 Mon Sep 17 00:00:00 2001 From: Viet-Tam Luu Date: Mon, 4 Dec 2017 14:21:41 -0800 Subject: [PATCH] Fix redundant file rename on Windows; just use cross-platform QFile calls. --- kml.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kml.cc b/kml.cc index f8ff4935b..4b75a8b6f 100644 --- a/kml.cc +++ b/kml.cc @@ -540,11 +540,10 @@ kml_wr_deinit() oqfile = NULL; if (!posnfilenametmp.isEmpty()) { -#if __WIN32__ - MoveFileExW((const wchar_t*) posnfilenametmp.utf16(), - (const wchar_t*) posnfilename.utf16(), - MOVEFILE_REPLACE_EXISTING); -#endif + // QFile::rename() can't replace an existing file, so do a QFile::remove() + // first (which can fail silently if posnfilename doesn't exist). A race + // condition can theoretically still cause rename to fail... oh well. + QFile::remove(posnfilename); QFile::rename(posnfilenametmp, posnfilename); } } -- 2.30.2